package com.yonyou.base.user.dao;

import com.yonyou.base.user.model.UserVO;
import com.yonyou.hrcloud.adder.ext.MBDao;
import com.yonyou.hrcloud.adder.model.query.Condition;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.data.domain.Sort;

import java.util.List;

/**
 * 用户管理DAO
 */
@MBDao
public interface IUserDao {

    @Insert("insert into rms_user (id,username,password,creationtime,creator,modifiedtime,modifier,version,dr) values (#{id},#{username},#{password},#{creationtime},#{creator},#{modifiedtime},#{modifier},0,0)")
    void insert(UserVO user);


    @Update("update rms_user set password = #{password} where id=#{id}")
    void resetUserPassword(@Param("password") String password, @Param("id") String id);


    @Select("<script>select * from rms_user <if test=\"condition != null\">where ${condition._CONDITION_}</if><if test=\"sort != null\">order by <foreach collection=\"sort\" item=\"order\" separator=\",\"> ${order.property} ${order.direction}</foreach></if></script>")
    List<UserVO> queryUserListByCondition(@Param("condition") Condition condition, @Param("sort") Sort sort);

}
